package models

type IssueModel struct {
	IssueId       int    `gorm:"column:issue_id"`
	IssueUser     string `gorm:"column:issue_user"`
	IssueDescribe string `gorm:"column:issue_describe"`
	IssueDetail   string `gorm:"column:issue_detail"`
	IssueSolve    int    `gorm:"column:issue_solve"`
	ProjectId     int    `gorm:"column:project_id"`
}

func NewIssueModel(fs ...func(i *IssueModel)) *IssueModel {
	i := new(IssueModel)
	for _, f := range fs {
		f(i)
	}
	return i
}

func WithIssueUser(iUser string) func(i *IssueModel) {
	return func(i *IssueModel) {
		i.IssueUser = iUser
	}
}

func WithIssueDescribe(iDesc string) func(i *IssueModel) {
	return func(i *IssueModel) {
		i.IssueDescribe = iDesc
	}
}

func WithIssueDetail(iDetail string) func(i *IssueModel) {
	return func(i *IssueModel) {
		i.IssueDetail = iDetail
	}
}

func WithIssueSolve(iSolve int) func(i *IssueModel) {
	return func(i *IssueModel) {
		i.IssueSolve = iSolve
	}
}

func WithProjectId(pId int) func(i *IssueModel) {
	return func(i *IssueModel) {
		i.ProjectId = pId
	}
}

func (i *IssueModel) TableName() string {
	return "issue"
}

type IssueWithProjectName struct {
	IssueId       int    `gorm:"column:issue_id"`
	IssueUser     string `gorm:"column:issue_user"`
	IssueDescribe string `gorm:"column:issue_describe"`
	IssueDetail   string `gorm:"column:issue_detail"`
	IssueSolve    int    `gorm:"column:issue_solve"`
	IssueStatus   string `gorm:"column:issue_status"`
	ProjectId     int    `gorm:"column:project_id"`
	ProjectName   string `gorm:"column:project_name"`
}

func (i *IssueWithProjectName) TableName() string {
	return "issue"
}
